<template>
  <el-row :gutter="20">
    <el-col :span="12">
      <div class="grid-content bg-purple">
        <div class="content ">
          <div class="header">
            <div class="title">
              日销售统计
            </div>
          </div>
          <div class="body">
            <div class="stats">
              <div class="num">{{ dayCount }}</div>
              <div class="text">当日销售量（个）</div>
            </div>
            <div class="stats">
              <div class="num">{{ dayAmount }}</div>
              <div class="text">当日销售额（元）</div>
            </div>
            <div class="stats">
              <div class="num">{{ dayBill }}</div>
              <div class="text">当日分成（元）</div>
            </div>
          </div>
        </div>
      </div>
    </el-col>
    <el-col :span="12">
      <div class="grid-content bg-purple">
        <div class="content content2">
          <div class="header">
            <div class="title">
              月销售统计
            </div>
          </div>
          <div class="body ">
            <div class="stats">
              <div class="num  color2">{{ mouthCount }}</div>
              <div class="text color3">当月销售量（个）</div>
            </div>
            <div class="stats">
              <div class="num color2">{{ mouthAmount }}</div>
              <div class="text color3">当月销售额（万元）</div>
            </div>
            <div class="stats">
              <div class="num color2">{{ mouthBill }}</div>
              <div class="text color3">当月分成（元）</div>
            </div>
          </div>
        </div>
      </div>
    </el-col>
  </el-row>
</template>

<script>
import { orderAmount, orderCout, totalBill } from '@/api'
import { parseTime } from '@/utils'
export default {
  data() {
    return {
      dayCount: null,
      dayAmount: null,
      dayBill: null,
      mouthCount: null,
      mouthAmount: null,
      mouthBill: null
    }
  },
  async created() {
    const dayTime = {
      start: parseTime(new Date(), '{y}-{m}-{d} 00:00:00'),
      end: parseTime(new Date(), '{y}-{m}-{d} 23:59:59')
    }
    const mouthTime = {
      start: parseTime(new Date(), `{y}-${(new Date()).getMonth() + 1}-01 00:00:00`),
      end: parseTime(new Date(), '{y}-{m}-{d} 23:59:59')
    }
    // 当日
    this.dayCount = (await orderCout(dayTime)).data
    this.dayAmount = (await orderAmount(dayTime)).data
    this.dayBill = (await totalBill(dayTime)).data
    // 当月
    this.mouthCount = (await orderCout(mouthTime)).data
    this.mouthAmount = ((await orderAmount(mouthTime)).data / 1000000).toFixed(2)
    this.mouthBill = ((await totalBill(mouthTime)).data / 100).toFixed(2)
  }
}
</script>

<style lang="scss" scoped>
@import "~@/styles/count.scss";
// .el-col-12{
//   padding-left:10px;
// }
.content2{
  background: #fbefe8 url(http://likede2-admin.itheima.net/img/sale.606b0d8c.png) no-repeat calc(100% - 12px) 100%;
}
.color2{
  color: #ff5757 !important;
  text-shadow: 2px 4px 7px rgb(255 99 85 / 50%) !important;
}
.color3{
  color: #de9690 !important;
}
</style>
